/*

*/

#ifndef FRAME_
#define FRAME_

#include "../include/vector3f.h"
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct frame {
	public:
	float time;
	vector<string>	names;
	vector<vector3f> relativeRotations;
	
	frame(){}

	frame(float totalTime, vector<string> nameVector, vector<vector3f> rotationVector){
		time = totalTime;
		names = nameVector;
		relativeRotations = rotationVector;
	}
	
	void load(ifstream &inData){
		//fprintf(stderr,"frame::load\n");
		string token;
		float x,y,z;
		names.clear();
		relativeRotations.clear();
		inData >> time;
		inData >> token;
		while(inData && token != "f"){
			inData >> x >> y >> z;
			names.push_back(token);
			relativeRotations.push_back(vector3f(x,y,z));
			inData >> token;
		}
		//fprintf(stderr,"Rotations in this frame: %d\nNames in this frame: %d\n",(int)relativeRotations.size(),(int)names.size());
		inData.unget();//put the 'f' back where it belongs
	}
	
	void print(string name){
		fprintf(stderr,"%s: %d\n",name.c_str(),(int)relativeRotations.size());
		for(int i = 0; i < (int)relativeRotations.size(); i++){
			fprintf(stderr,"\t%s\t%.2f %.2f %.2f\n",
				names[i].c_str(),
				relativeRotations[i].v[0],
				relativeRotations[i].v[1],
				relativeRotations[i].v[2]
			);
		}
	}
};

#endif /*FRAME_*/
